using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NewAndong.Entity;
using NewAndong.Model;
using Leeder.Service;
using Leeder.Repository;

namespace NewAndong.Service
{
    /// <summary>
    /// 
    /// </summary>
   public class SignalLampDirectionService : BaseService<SignalLampDirectionModel>
   {
        /// <summary>
        /// 关联实体类型
        /// </summary>
        protected override Type RefEntityType { get { return typeof(SignalLampDirectionEntity); } }

        public SignalLampDirectionModel GetOne(SignalLampDirectionModel input)
        {

            var result = new SignalLampDirectionModel();
            var query = RF<SignalLampDirectionEntity>.Queryable();
            query.WhereIF(!string.IsNullOrEmpty(input.LampName), w => w.LampName == input.LampName);
            var list = query.ToList();

            if (list.Count > 0)
            {
                var first = list.FirstOrDefault();
                result.ChainMark = first.ChainMark;
                result.SignalLampMappingID = first.SignalLampMappingID;
                result.Status = first.Status;
                result.IsPhantom = first.IsPhantom;
                result.Enable = first.Enable;
                result.EndDelayCount = first.EndDelayCount;
                result.ID = first.ID;
                result.LampCode = first.LampCode;
                result.LampDescription = first.LampDescription;
                result.LampName = first.LampName;
                result.TriggerCount = first.TriggerCount;
                result.TriggerDelayCount = first.TriggerDelayCount;
                result.TypeId = first.TypeId;
                result.TypeName = first.TypeName;
                result.UnpackingId = first.UnpackingId;

            }

            return result;

        }
    }
}